package org.nobject.common.lang;

/**
 * ExceptionUtils
 *
 * @author bianrongjun
 * @version 1.0
 */
public class ExceptionUtils {
	
	public static String getStacks(Exception e){
		StringBuffer sb=new StringBuffer();
		sb.append(e.getMessage()).append("\n");
		StackTraceElement[] msgs = e.getStackTrace();
		for (int i = 0; i < msgs.length; i++) {
			StackTraceElement msg=msgs[i];
			sb	.append(msg.getClassName())
				.append("#")
				.append(msg.getMethodName())
				.append("(")
				.append(msg.getFileName())
				.append(":")
				.append(msg.getLineNumber())
				.append(")")
				.append("\n");
		}
		return sb.toString();
	}
	
	public static void main(String[] args) {
		
		try {
			Integer.parseInt("ss");
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println(getStacks(e));
			// TODO: handle exception
		}
		
		
	}
	
}
